package com.newcapec.servlet;

import com.newcapec.bean.ColumnEntity;
import com.newcapec.bean.UserEntity;
import com.newcapec.service.ColumnService;
import com.newcapec.service.impl.ColumnServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @Description:显示发布新闻的servlet类
 * @Author:yangshupeng
 * @Date: 2022/3/21 22:11
 * @Version:1.0
 */
@WebServlet("/releaseNews.html")
public class ShowReleaseNewsHtmlServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //跳转发布新闻的jsp页面，我们给jsp页面传一些数据
        ColumnService columnService = new ColumnServiceImpl();
        List<ColumnEntity> columnList = columnService.queryAll();

        //通过请求域的共享属性，传递给jsp页面
        req.setAttribute("columnList",columnList);

        //请求转发
        req.getRequestDispatcher("WEB-INF/jsp/releaseNewsManagement.jsp").forward(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}
